"""
数据加载模块
负责加载和处理车辆、货物数据
"""
import pandas as pd
from typing import List, Dict, Tuple

# 假设这些变量在主程序中定义或从外部导入
# vehicle_df = None
# cargo_df = None
# real_data_dict = None

def load_vehicle_data(vehicle_df: pd.DataFrame, max_index: int) -> Dict[int, Tuple]:
    """
    加载车辆数据到队列

    参数:
        vehicle_df: 车辆数据DataFrame
        max_index: 最大车辆索引

    返回:
        车辆队列字典
    """
    vehicle_queue = {}
    # 假设数据格式: ID, Type, Capacity, etc.
    for _, row in vehicle_df.iterrows():
        vehicle_id = int(row[0])
        if vehicle_id > max_index:
            vehicle_attr = (row[1], row[2], row[3], row[4:6], row[6:8], row[8:10])
            vehicle_queue[vehicle_id] = (vehicle_id, vehicle_attr)
    return vehicle_queue

def load_cargo_data(cargo_df: pd.DataFrame, max_index: int) -> Dict[int, Tuple]:
    """
    加载货物数据到队列

    参数:
        cargo_df: 货物数据DataFrame
        max_index: 最大货物索引

    返回:
        货物队列字典
    """
    cargo_queue = {}
    # 假设数据格式: ID, Type, Weight, etc.
    for _, row in cargo_df.iterrows():
        cargo_id = int(row[0])
        if cargo_id > max_index:
            cargo_attr = (row[1], row[2], row[3], row[4:6], row[6:8], row[8:10])
            cargo_queue[cargo_id] = (cargo_id, cargo_attr)
    return cargo_queue

def get_vehicle_prior(vehicle_queue: List[Tuple]) -> Dict[str, float]:
    """
    计算车辆属性先验概率

    参数:
        vehicle_queue: 车辆队列

    返回:
        车辆属性先验概率字典
    """
    # 实际实现应根据具体数据结构计算
    return {"type": 0.5, "capacity": 0.3, "other": 0.2}

def get_cargo_prior(cargo_queue: List[Tuple]) -> Dict[str, float]:
    """
    计算货物属性先验概率

    参数:
        cargo_queue: 货物队列

    返回:
        货物属性先验概率字典
    """
    # 实际实现应根据具体数据结构计算
    return {"type": 0.4, "weight": 0.4, "other": 0.2}